home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / debugc.zip / BUG.C next >
Text File  |  1985-02-20  |  1KB  |  66 lines

  1. #include bug.h
  2. #include stdio.h
  3.  
  4.       /*  *****************************************************  */
  5.       /*  Dr. Bob's Utilities    Copyright (c) 1985              */
  6.       /*  DEBUG  preprocessor macro example                      */
  7.       /*  compile with  cc -ddebug bug.c     to see debug stuff  */
  8.       /*  *****************************************************  */
  9.  
  10.  
  11. main()
  12. {
  13.     int n;
  14.  
  15.     DB_PRINT("Debug is active\n\n");
  16.     NDB_PRINT("Debug is NOT active\n\n");
  17.  
  18.     HERE("main");
  19.  
  20.     readfile();
  21.  
  22.     DEBUG(
  23.        printf("\n\nIf debug is defined only two calls to ");
  24.        printf("sortfile() will be made here\n");
  25.        sortfile();
  26.        sortfile();
  27.     )
  28.     HERE("main2");
  29.  
  30.     N_DEBUG(
  31.        printf("Statements in this section will execute only if debug is NOT defined.\n");
  32.        for(n = 1; n <= 8; n++)
  33.        sortfile();
  34.     )
  35.  
  36.     writefile();
  37.     printf("\n");
  38.     HERE("main3");
  39.  
  40.     printf("\nThis should be printed no matter what\n");
  41.  
  42. }
  43.  
  44.  
  45. readfile()
  46. {
  47.     HERE("readfile");
  48. }
  49.  
  50.  
  51. sortfile()
  52. {
  53.     static int i = 1;
  54.     DB_PRINT("      sortfile - pass #%d \n" COMMA i++);
  55.     NDB_PRINT ("sf() - pass #%d \n" COMMA i++);
  56. }
  57.  
  58.  
  59. writefile()
  60. {
  61.     static char st[] = "This message created by writefile";
  62.     HERE("writefile");
  63.     DB_PRINT("\nThe string is: %s\n" COMMA st);
  64. }en through debugging, use:
  65.  
  66.